<?php

namespace app\consts;

class Lang
{
    const ZH_CN = "zh_CN";
    const EN = "en";

    /**
     * 获取语言配置
     * @return array[]
     */
    public static function config()
    {
        return [
            ["id" => 1, "name" => "简体中文", "open" => 1, "lang" => static::ZH_CN, "icon" => ""],
            ["id" => 2, "name" => "ENGLISH", "open" => 1, "lang" => static::EN, "icon" => ""],
        ];
    }

    /**
     * 根据语言标识查找语言id，找不到就是0
     * @param string $lang
     * @return int
     */
    public static function id(string $lang) :int
    {
        $find = collect(static::config())->where("lang","=",$lang)->first();
        return $find ? $find["id"] : 0 ;
    }
}